using System;
using System.Web;
using System.Web.UI;

namespace Orbitone.MeetingRooms.RoomFinder.UserControls
{
    public partial class LiveConnectUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies[Globals.COOKIE_NAME] == null)
            {
                login.NavigateUrl = Globals.ENDPOINT_OAUTH +
                                    Globals.ENDPOINT_PATH_AUTHORIZE +
                                    Globals.PARAM_CLIENT_ID +
                                    Globals.APP_CLIENT_ID +
                                    Globals.PARAM_SCOPE +
                                    Globals.REQUESTED_SCOPES +
                                    Globals.PARAM_RESPONSE_TYPE +
                                    Globals.PARAM_RESPONSE_TYPE_CODE +
                                    Globals.PARAM_REDIRECT_URI +
                                    Globals.APP_REDIRECT_URI;
                login.Text = "Login";
            }
            else
            {
                name.Text = Request.Cookies[Globals.COOKIE_NAME]["name"];
                login.NavigateUrl = VirtualPathUtility.ToAbsolute("~/") + "Logout.aspx";
                login.Text = "Logout";
            }
        }
    }
}